home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / ZIPArchiver.java < prev    next >
Text File  |  1998-10-14  |  2KB  |  101 lines

  1. package com.symantec.itools.tools.archive;
  2.  
  3.  
  4. import java.io.File;
  5. import java.io.IOException;
  6. import com.symantec.itools.lang.Classpath;
  7. import com.symantec.itools.lang.NotJavaNameException;
  8. import com.symantec.itools.io.FileSystem;
  9. import com.symantec.itools.lang.Debug;
  10. import com.symantec.itools.lang.ProcessManager;
  11.  
  12.  
  13. /**
  14.  * @author Symantec Internet Tools Division
  15.  * @version 1.0
  16.  * @since VCafe 3.0
  17.  */
  18.  
  19. public class ZIPArchiver
  20.     extends TypeArchiver
  21. {
  22.  
  23.     /**
  24.      * @since VCafe 3.0
  25.      */
  26.     protected ProcessManager processManager;
  27.  
  28.     public ZIPArchiver(Options options)
  29.     {
  30.         super(options);
  31.     }
  32.  
  33.     /**
  34.      * @param errorMsg TODO
  35.      * @since VCafe 3.0
  36.      */
  37.  
  38.     public boolean create(StringBuffer errorMsg)
  39.     {
  40.         return (createUsingSunJAR(errorMsg));
  41.     }
  42.  
  43.     /**
  44.      * @param errorMsg TODO
  45.      * @since VCafe 3.0
  46.      */
  47.  
  48.     protected boolean createUsingSunJAR(StringBuffer errorMsg)
  49.     {
  50.         DirectoryArchiver archiver;
  51.         String            outFile;
  52.         String            manifestFile;
  53.         StringBuffer      command;
  54.         String            tempDir;
  55.  
  56.         outFile = options.getOutputLocation();
  57.         tempDir = options.getTempDir();
  58.         options.setOutputLocation(tempDir);
  59.         archiver     = new DirectoryArchiver(options);
  60.         manifestFile = null;
  61.  
  62.         if(!(archiver.create(errorMsg)))
  63.         {
  64.             return (false);
  65.         }
  66.  
  67.         options.setOutputLocation(outFile);
  68.         command = new StringBuffer(FileSystem.quoteIfNeeded(FileSystem.getCanonicalPath(options.getSunTools(), true) + "jar.exe"));
  69.         command.append(' ').append(options.getArchiverArgs());
  70.         
  71.         try
  72.         {
  73.             processManager = new ProcessManager();
  74.  
  75.             if(processManager.monitorLaunchedProcess(Runtime.getRuntime().exec(command.toString())) != 0)
  76.             {
  77.                 return (false);
  78.             }
  79.         }
  80.         catch(IOException ex)
  81.         {
  82.             Debug.logException(ex);
  83.             return (false);
  84.         }
  85.  
  86.         return (true);
  87.     }
  88.  
  89.     /**
  90.      * @since VCafe 3.0
  91.      */
  92.  
  93.     public void cancel()
  94.     {
  95.         if(processManager != null)
  96.         {
  97.             processManager.destroyProcess();
  98.             processManager = null;
  99.         }
  100.     }
  101. }